package com.ldn.server.boot3.starter.feign;

import com.ldn.common.basic.dispose.bo.MqttClientInfo;
import com.ldn.common.basic.dispose.dto.PageDto;
import com.ldn.common.basic.dispose.vo.ResultDataVo;
import com.ldn.database.dao.entities.Page;
import com.ldn.server.boot3.starter.interceptor.MyFeignRequestInterceptor;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @author 李大牛家的牛 (scafel@163.com)
 * @product serverless
 * @className ServerMqtt
 * @createDate 2025/2/10 - 9:24
 * @description ToDo...
 **/
@FeignClient(
        name = "server-mqtt",
        path = "mqtt-service",
        configuration = MyFeignRequestInterceptor.class
)
public interface ServerMqtt {

    /**
     * 踢掉客户端
     * 具体查看 {@link com.ldn.server.mqtt.controller.ServiceController#kick} 方法
     * @param clientId 客户端ID
     */
    @PostMapping("service/kick/{clientId}")
    void kick(@PathVariable String clientId);

    /**
     * 获取客户端分页列表
     * 具体查看 {@link com.ldn.server.mqtt.controller.ServiceController#getClientPage} 方法
     * @param dto 分页信息
     * @return 客户端分页信息
     */
    @PostMapping("service/client/page")
    ResultDataVo<Page<MqttClientInfo>> getClientPage(@RequestBody PageDto dto);

    /**
     * 获取服务端统计信息
     * 具体查看 {@link com.ldn.server.mqtt.controller.ServiceController#getStat} 方法
     * @return 统计信息
     */
    @GetMapping("service/stat")
    ResultDataVo<Object> getStat();

    /**
     * 发布消息
     * 具体查看 {@link com.ldn.server.mqtt.controller.ServiceController#publishAll} 方法
     * @param topic 主题
     * @param body 消息体
     * @return 是否成功
     */
    @PostMapping("service/publish/{topic}")
    ResultDataVo<Boolean> publishAll(
            @PathVariable("topic") String topic,
            @RequestBody String body
    );
    /**
     * 发布消息
     * 具体查看 {@link com.ldn.server.mqtt.controller.ServiceController#publish} 方法
     * @param topic 主题
     * @param clientId 客户端ID
     * @param body 消息体
     * @return 是否成功
     */
    @PostMapping("service/publish/{topic}/{clientId}")
    ResultDataVo<Boolean> publish(
            @PathVariable("topic") String topic,
            @PathVariable("clientId") String clientId,
            @RequestBody String body
    );

    /**
     * 获取客户端订阅的主题
     * 具体查看 {@link com.ldn.server.mqtt.controller.ServiceController#getTopic} 方法
     * @param clientId 客户端ID
     * @return 客户端订阅的主题
     */
    @GetMapping("service/topic/{clientId}")
    ResultDataVo<List<String>> getTopic(@PathVariable("clientId") String clientId);

    /**
     * 获取客户端订阅的主题
     * 具体查看 {@link com.ldn.server.mqtt.controller.ServiceController#getAllTopic} 方法
     * @return 客户端订阅的主题
     */
    @GetMapping("service/all/topic")
    ResultDataVo<List<String>> getAllTopic();

}
